﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CutShuFa
{
    public partial class CutSettingForm : Form
    {
        public CutSettingForm()
        {
            InitializeComponent();
            CutSetting cutSetting = CutSetting.LoadCutSetting();
            if (cutSetting != null)
            {
                tb_TextFilePath.Text = cutSetting.TextFilePath;
                tb_SaveImageFolder.Text = cutSetting.SaveImageFolder;
            }
        }

        private void bt_TextFilePath_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "文本文件|*.txt";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                tb_TextFilePath.Text = openFileDialog.FileName;
            }
        }

        private void bt_SaveImageFolder_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                tb_SaveImageFolder.Text = folderBrowserDialog.SelectedPath;
            }
        }

        private void bt_save_Click(object sender, EventArgs e)
        {
            CutSetting cutSetting = new CutSetting();
            cutSetting.SaveImageFolder = tb_SaveImageFolder.Text;
            cutSetting.TextFilePath = tb_TextFilePath.Text;
            cutSetting.SaveCutSetting();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void bt_cancle_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
